<?php

namespace Common\Model\Cache;

class Nav extends Base
{
    public function refresh()
    {
        $menu = M("Nav");
        $data = $menu->where(' display = 1 ')->order('sort desc,id asc')->select();
        foreach ($data as $v) {
            $dli['type'] = $v['type'];
            $dli['title'] = $v['title'];
            $dli['pagealias'] = $v['pagealias'];
            $dli['target'] = $v['target'] ? "_blank" : "_self";
            if ($v['type'] == '1') {
                $dli['url'] = $v['url'] ? $v['url'] : C('YTATA_SITE_DOMAIN') . __ROOT__ . '/';
            } else {
                if ($v['act'] && $v['fun']) {
                    $dli['url'] = $v['act'] . "/" . $v['fun'];
                    $dli['url'] = U($dli['url']);
                } else {
                    $dli['url'] = C('YTATA_SITE_DOMAIN') . __ROOT__ . '/';
                }
            }
            $navli[] = $dli;
        }
        $this->save($navli);
        return $navli;
    }

}